#SingleInstance force
U_GVIM := "C:\tool\tcee\tools\vim\gvim.exe"
U_DESKTOP := ""
U_TC := "C:\tool\tcee\totalcmd.exe"
U_OUTLOOK := "C:\Program Files (x86)\Microsoft Office\Office12\OUTLOOK.EXE"
U_EVERYTHING := "c:\tool\Everything-1.2.1.371.exe"
U_CHROME := "C:\Documents and Settings\tangw\Local Settings\Application Data\Google\Chrome\Application\chrome.exe"
U_EVERNOTE := "c:\Program Files (x86)\Evernote\Evernote\Evernote.exe"
U_MYMONEYMASTER := "c:\Dropbox\MyMoneyMaster\Professional3\MyMoneyMaster.exe"
U_DROPBOX := "C:\Documents and Settings\tangw\Application Data\Dropbox\bin\Dropbox.exe"
U_ACTIVE_ID :=""

IfExist, tw.ico
   Menu, tray, icon, tw.ico

IniRead, if_reload, ahk_setting.ini, tw, if_reload, 0
if ( 0 = if_reload )
{
   ;sleep, 1000*60*1
   ;run, "C:\Program Files\Code Collaborator Client\ccollabtray.exe"
   ;sleep, 1000*60*1
   ;run, "C:\Program Files\CCTray\cctray.exe"
   ;sleep, 1000*60*3
   ;run, %U_OUTLOOK%
   ;sleep, 1000*60*3
   ;run, "c:\Program Files\Microsoft Office Communicator\communicator.exe"
   ;sleep, 1000*60*3
   ;run, "C:\Program Files\Windows Live\Messenger\msnmsgr.exe"
   ;sleep, 1000*60*3
   ;run, "C:\Program Files\Microsoft Office\Office12\ONENOTEM.EXE" /tsr
   ;sleep, 1000*60*3
   ;run, "C:\Program Files\MozyEnterprise\mozyentstat.exe"
}
IniWrite, 0, ahk_setting.ini, tw, if_reload

;!z::
;return

;!g::
;return

!c:: run, %U_CHROME%
!e:: run, %U_EVERNOTE%
!f:: run, %U_EVERYTHING%
;!d:: run, %U_DESKTOP%

^!m::
GoSub, RUN_MyMoneyMaster
return

RUN_MyMoneyMaster:
Process, Exist, Dropbox.exe
if ErrorLevel
{
   Process, Close, Dropbox.exe
   sleep 1000
}
run, %U_MYMONEYMASTER%
Process, WaitClose, MyMoneyMaster.exe, 300
run, %U_DROPBOX% /home
return

;
; Important Script Begin
;
#a:: ;edit the AutoHotKey Script
!a::
IfWinExist %A_ScriptName%
{
   WinClose
   IniWrite, 1, ahk_setting.ini, tw, if_reload
   Reload
}
else
{
   run, %U_GVIM% %A_ScriptFullPath%
   WinWait, %A_ScriptName%
   WinActivate
   ;WinMaximize
}
return

#q:: ;Total Commander
!q::
DetectHiddenWindows, on
IfWinActive, ahk_class TTOTAL_CMD ; Total Commander
{
   WinHide, ahk_class TTOTAL_CMD
   WinShow, ahk_id %U_ACTIVE_ID%
   WinActivate, ahk_id %U_ACTIVE_ID%
}
else
{
   WinGet, U_ACTIVE_ID, ID, A
   IfWinNotExist, ahk_class TTOTAL_CMD
   {
      run, %U_TC%
      WinWait, ahk_class TNASTYNAGSCREEN, 1
      WinActivate, ahk_class TNASTYNAGSCREEN
      ControlGetText, num, TPanel2
      send, %num%
   }
   else
   {
      WinShow, ahk_class TTOTAL_CMD
      WinActivate, ahk_class TTOTAL_CMD
   }
}
DetectHiddenWindows, off
return

#IfWinActive, Lister
F3:: send {Alt down}{F4}{Alt up}
;
; Important Script End
;

!d:: 
IfWinNotExist, worklog.note
{
   run, %U_GVIM% "c:\Documents and Settings\tangw\Desktop\worklog.note"
}
else
{
   WinClose
}
return

!s:: 
IfWinNotExist, tw.note
{
   run, %U_GVIM% "C:\Dropbox\Willin\tw.note"
}
else
{
   WinClose
}
return

;#w:: ;Outlook
;!w::
;DetectHiddenWindows, on
;IfWinNotActive, ahk_class rctrl_renwnd32
;{
;   IfWinNotExist, ahk_class rctrl_renwnd32
;   {
;      run, %U_OUTLOOK%
;   }
;   else
;   {
;      WinShow, ahk_class rctrl_renwnd32
;      WinActivate, ahk_class rctrl_renwnd32
;   }
;}
;else
;{
;   WinMinimize, ahk_class rctrl_renwnd32
;}
;DetectHiddenWindows, off
;return



!w::
IfWinActive, Debug Mode
{
   WinActivate, OGSTestcases_x86_debug - Microsoft Visual Studio (Administrator)
   WinWaitActive, OGSTestcases_x86_debug - Microsoft Visual Studio (Administrator)
   send, ^!d
}
else ifWinExist, Debug Mode
{
   WinActivate, Debug Mode
}
return

#IfWinActive, DirectX Texture Tool
F9:: send {Alt down}{F4}{Alt up}


